<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    // 把伪数组转成数组
    // 展开运算符、Array.from();
    function fn(){
        // 转成数组
        // var arr = [...arguments];
        var arr = Array.from(arguments);
    }
    fn(1,2,3);
    
    // Array.of()
    let arr1 = new Array(7);
    let arr2 = new Array(7,8);
    console.log(arr1);
    console.log(arr2);

    var arr3 = Array.of(7);
    console.log(arr3);


    // find & findIndex
    var arr4 = ["abc","def","hg"];
    var res = arr4.find(function(item){
        return item ==="def";
    })
    console.log(res);

    var arr5 = [1,2,3,4,5];
    var res1 = arr5.find(item=>item>3);
    console.log(res1); // 4
    var res2 = arr5.filter(item=>item>3);
    console.log(res2); // 4 5

    var res3 = arr5.findIndex(item=>item>3);
    console.log(res3); // 3


    // flat():数组的扁平化  把数组降维
    var arr6 = [1,2,3,[4,5,[6,[7,[8]]]]];
    var newarr = arr6.flat(4);
    console.log(newarr);


    // at() 获取数组里的值
    var arr7 = ["abc","def","hg"];
    console.log(arr7.at(1));


    // fill() 填充数组里的键值
    var arr8 = [1,2,3,4,5];
    // var res4 = arr8.fill("a");
    var res4 = arr8.fill("a",1,4);
    console.log(res4);


    // includes() 判断数组里是否包含某个值
    var arr9 = ["abs","hfg","lk"];
    console.log(arr9.includes("hfg"));




</script>